<!Doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>大旺福--{$title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/assets/layui/css/global.css" media="all">
    <link rel="stylesheet" href="/assets/layui/css/admin.css" media="all">
</head>
<body>
<div class="layui-layout layui-layout-admin">

    <!-- header start -->
    {include file="layout/header.html"}
    <!-- header end -->

    <!-- nav start-->
    {include file="layout/nav.html"}
    <!-- nav end-->

    <!-- main start -->
    <div class="layui-body site-demo">
        <div class="layui-main">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>{$title}</legend>
            </fieldset>
            <div class="site-block">
                <div class="operating">
                    <a href="javascript:void(0);"><button class="layui-btn layui-btn-small" type="button" onclick="window.location.href='/product/productEdit/'"><i class="layui-icon">&#xe61f;</i>添加商品</button></a>
                    <a href="javascript:void(0);"><button class="layui-btn layui-btn-small" type="button" onclick="selectAll('id[]')"><i class="layui-icon">&#xe605;</i>全选</button></a>
                    <a href="javascript:void(0);"><button class="layui-btn layui-btn-small layui-btn-danger" type="button" onclick="goods_del()"><i class="layui-icon">&#x1006;</i>删除</button></a>
                    <a href="javascript:void(0);"><button class="layui-btn layui-btn-small" type="button" onclick="goods_shelf(1)"><i class="layui-icon">&#xe62f;</i>上架</button></a>
                    <a href="javascript:void(0);"><button class="layui-btn layui-btn-small" type="button" onclick="goods_shelf(0)"><i class="layui-icon">&#xe601;</i>下架</button></a>
                    <a href="javascript:void(0);"><button class="layui-btn layui-btn-small" type="button" onclick="goods_stats('check')"><i class="layui-icon">&#xe607;</i>待审</button></a>
                </div>
                <hr>
                <div class="searchbar">
                    <form action="#" method="get" class="layui-form search-from">
                        <input type="hidden" name="search_list" value='{$search_array_str}'/>
                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <select class="auto" name="search[shop_id]">
                                    <option value="">选择供应商</option>
                                    {foreach from=$shop item=one}
                                    <option value="{$one.id}" {if $search_array.shop_id eq $one.id}selected{/if}>{$one.shop_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[shelf]">
                                    {if $search_array.shelf eq ''}
                                    <option value="" selected>选择上下架</option>
                                    <option value="1">上架</option>
                                    <option value="0">下架</option>
                                    {else}
                                    <option value="">选择上下架</option>
                                    <option value="1" {if $search_array.shelf eq 1}selected{/if}>上架</option>
                                    <option value="0" {if $search_array.shelf eq 0}selected{/if}>下架</option>
                                    {/if}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[status]">
                                    {if $search_array.status eq ''}
                                    <option value="" selected>选择状态</option>
                                    <option value="1">待审核</option>
                                    <option value="2">审核通过</option>
                                    <option value="0">审核未通过</option>
                                    {else}
                                    <option value="">选择状态</option>
                                    <option value="1" {if $search_array.status eq 1}selected{/if}>待审核</option>
                                    <option value="2" {if $search_array.status eq 2}selected{/if}>审核通过</option>
                                    <option value="0" {if $search_array.status eq 0}selected{/if}>审核未通过</option>
                                    {/if}
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[name]">
                                    <option value="name" {if $search_array.name eq 'name'} selected{/if}>商品名</option>
                                    <option value="goods_no" {if $search_array.name eq 'goods_no'} selected{/if}>商品货号</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="search[keywords]"  autocomplete="off" class="layui-input" value="{$search_array.keywords}">
                            </div>
                            <div class="layui-input-inline">
                                <select class="auto" name="search[stock]">
                                    {if $search_array.stock eq ''}
                                    <option value="" selected>选择备货</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                    {else}
                                    <option value="">选择备货</option>
                                    <option value="1" {if $search_array.stock eq 1}selected{/if}>是</option>
                                    <option value="0" {if $search_array.stock eq 0}selected{/if}>否</option>
                                    {/if}
                                </select>
                            </div>
                            <div class="layui-input-inline button-warp">
                                <input type="hidden" name="search[categroy_select_id]" value="">
                                <button type="button" class="layui-btn layui-btn-warm layui-btn-small category-select" style="margin-top:5px;"><i class="layui-icon">&#xe608;</i> <span>选择分类</span></button>
                            </div>
                            <div class="layui-input-inline button-warp">
                                <button type="button" class="layui-btn layui-btn-small search-button" style="margin-top:5px;"><i class="layui-icon">&#xe615;</i> <span>筛选</span></button>
                            </div>
                        </div>
                        <!--<button class="btn" onclick="changeAction(true)"><span class="sel">导出Excel</span></button>-->
                    </form>
                </div>
                <hr />
                <div class="content">
                    <table class="list_table">
                        <colgroup>
                            <col width="40px">
                            <col width="40px">
                            <col width="360px">
                            <col width="180px">
                            <col width="90px">
                            <col width="70px">
                            <col width="80px">
                            <col width="70px">
                            <col width="60px">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>选择</th>
                            <th>商品id</th>
                            <th>商品名称</th>
                            <th>分类</th>
                            <th>销售价</th>
                            <th>是否备货</th>
                            <th>状态</th>
                            <th>排序</th>
                            <th>操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        {foreach from=$products item=product}
                        <tr class="sel">
                            <td><input name="id[]" type="checkbox" value="{$product.id}"></td>
                            <td>{$product.id}</td>
                            <td>{$product.product_name}</td>
                            <td>{foreach from=$product.category item=categoty}[{$categoty.category_name}]{/foreach}</td>
                            <td><a href="javascript:quickEdit('{$product.id}','price');" class="orange" title="点击更新价格" id="priceText{$product.id}"><span class="layui-icon">&#xe642;</span>修改</a></td>
                            <td>
                                <select onchange="changeIsStock('{$product.id}',this)" data-id="{$product.id}">
                                    <option value="1" {if $product.stock eq 1} selected{/if}>是</option>
                                    <option value="0" {if $product.stock eq 0} selected{/if}>否</option>
                                </select>
                            </td>
                            <td>
                                <select onchange="changeIsShelf({$product.id},this)">
                                    <option value="1" {if $product.shelf eq 1} selected{/if}>上架</option>
                                    <option value="0" {if $product.shelf eq 0} selected{/if}>下架</option>
                                </select>
                            </td>
                            <td><input type="text" class="tiny" value="{$product.f_order}" onchange="changeSort('{$product.id}',this);"></td>
                            <td>
                                <a href="/product/productEdit/{$product.id}" class='orange layui-icon'>&#xe63c;</a>
                                <a href="javascript:void(0)" onclick="delete_goods('{$product.id}')" class='orange layui-icon'>&#xe640;</a>
                            </td>
                        </tr>
                        <tr class="even">
                            <td colspan="3">&nbsp;</td>
                            <td>规格</td>
                            <td>价格</td>
                            <td>实库</td>
                            <td>虚库</td>
                            <td>单位</td>
                            <td>状态</td>
                        </tr>
                        {foreach from=$product.goodsList item=goods}
                        <tr>
                            <td colspan="3">&nbsp;</td>
                            <td>
                                {if $goods.spec_array|count eq 0}
                                默认
                                {else}
                                {foreach from=$goods.spec_array item=sku}
                                {$sku.value}
                                {/foreach}
                                {/if}
                            </td>
                            <td><input type="text" class="tiny" value="{$goods.sell_price}" onchange="changeSkuAttr('{$goods.id}',this,'price');"></td>
                            <td>{$goods.store_nums_real}</td>
                            <td><input type="text" class="tiny" value="{$goods.store_nums}" onchange="changeSkuAttr('{$goods.id}',this,'store');"></td>
                            <td><input type="text" class="tiny" value="{$goods.precise_unit}" onchange="changeSkuAttr('{$goods.id}',this,'precise');"></td>
                            <td>
                                <select onchange="changeSkuAttr('{$goods.id}',this,'shelf');">
                                    <option value="1" {if $goods.shelf eq 1}selected{/if}>上架</option>
                                    <option value="0" {if $goods.shelf eq 0}selected{/if}>下架</option>
                                </select>
                            </td>
                        </tr>
                        {/foreach}
                        {/foreach}
                        </tbody>
                    </table>
                </div>
                <div class="layui-box layui-laypage layui-laypage-default">
                    {$pageStr}
                    <span>当前第{$currentPage}页/共{$totalPage}页</span>
                </div>
            </div>

        </div>
    </div>
    <!-- main end -->

</div>
<div id="category-content" style="display: none;">
    <input type="hidden" name="categroy_id" value="0">
    <button type="button" class="layui-btn layui-btn-warm layui-btn-small add-category layui-hide" style="margin-top:5px;"><i class="layui-icon">&#xe608;</i> <span>选择分类</span></button>
    <div class="category-list layui-clear site-block" style="padding:10px;">
        <ul id="category-tree" class="layui-box layui-tree" style="margin-bottom:10px;"></ul>
    </div>
</div>
<!--库存更新模板-->
{literal}
<script id="goodsStoreTemplate" type="text/html">
    <div class="quickEditForm-content">
        <form name="quickEditForm">
            <table class="border_table" style="width:100%">
                <thead>
                <tr>
                    <th>商品</th>
                    <th>库存量</th>
                </tr>
                </thead>
                <tbody>
                {{# layui.each(d.list, function(index, item){ }}
                <tr>
                    <td>
                        {{item.product_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# if(item['spec_array']){ }}
                        {{# layui.each(item['spec_array'], function(i, e){ }}
                        {{e.name}}:{{e.value.value_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# })}}
                        {{# } }}
                    </td>
                    <td>
                        <input type="text" class="small" name="data[{{item['id']}}]" value="{{item['store_nums']}}" />
                    </td>
                </tr>
                {{# }) }}
                </tbody>
            </table>
            <input type='hidden' name='product_id' value="{{d.productId}}" />
        </form>
    </div>
</script>
<!--价格更新的模板-->
<script id="goodsPriceTemplate" type="text/html">
    <div class="quickEditForm-content">
        <form name="quickEditForm">
            <table class="border_table" style="width:100%">
                <thead>
                <tr>
                    <th>商品</th>
                    <th>市场价</th>
                    <th>销售价</th>
                    <th>成本价</th>
                    <th>返现金额</th>
                    <th>商家分成金额</th>
                    <th>区域经理分成金额</th>
                </tr>
                </thead>
                <tbody>
                {{# layui.each(d.list, function(index, item){ }}
                <tr>
                    <td>
                        {{item.product_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# if(item['spec_array']){ }}
                        {{# layui.each(item['spec_array'], function(i, e){ }}
                        {{e.name}}:{{e.value.value_name}}
                        &nbsp;&nbsp;&nbsp;
                        {{# })}}
                        {{# } }}
                    </td>
                    <td><input type="text" class="small" name="data[{{item.id}}][market_price]" value="{{item['market_price']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][sell_price]" value="{{item['sell_price']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][cost_price]" value="{{item['cost_price']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][cash_back]" value="{{item['cash_back']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][proportion]" value="{{item['proportion']}}" /></td>
                    <td><input type="text" class="small" name="data[{{item.id}}][area_proportion]" value="{{item['area_proportion']}}" /></td>
                </tr>
                {{# }) }}
                </tbody>
            </table>
            <input type='hidden' name='product_id' value="{{d.productId}}" />
        </form>
    </div>
</script>
{/literal}
{include file="layout/footerJs.html"}
<script src="/assets/layui/js/product/product_list.js"></script>
</body>
</html>